﻿#ifndef TRCHARTCOLOR_H
#define TRCHARTCOLOR_H

#include <QWidget>

#if defined(_MSC_VER) && (_MSC_VER >= 1600)
# pragma execution_character_set("utf-8")
#endif

#define MAX_INSTRUMENT_LENGTH	32
#define MAX_EXCHANGE_LENGTH		16


enum TrKlinePeriod
{
    KP_Tick = 0,
    KP_Minute1 = 1,
    KP_Minute5 = 2,
    KP_Minute15 = 3,
    KP_Minute60 = 4,
    KP_DAY = 5,
    KP_Week = 6
};

//By Wesley @ 2021.12.31
//新的结构体，全部改成8字节对齐的方式
#pragma pack(push, 8)

struct WTSBarStruct
{
public:
    WTSBarStruct()
    {
        memset(this, 0, sizeof(WTSBarStruct));
    }
    uint32_t	date;		//日期
    uint32_t	reserve_;	//占位符
    uint64_t	time;		//时间
    double		open;		//开
    double		high;		//高
    double		low;		//低
    double		close;		//收
    double		settle;		//结算
    double		money;		//成交金额
    double		vol;		//成交量
    union
    {
        double		hold;	//总持
        double		bid;	//买价，期权专用，主要期权spread比较大，By Wseley @ 2023.05.04
    };
    union
    {
        double		add;	//增仓
        double		ask;	//卖价，期权专用，主要期权spread比较大，By Wseley @ 2023.05.04
    };
};

struct WTSTickStruct
{
    char		exchg[MAX_EXCHANGE_LENGTH];
    char		code[MAX_INSTRUMENT_LENGTH];

    double		price;				//最新价
    double		open;				//开盘价
    double		high;				//最高价
    double		low;				//最低价
    double		settle_price;		//结算价

    double		upper_limit;		//涨停价
    double		lower_limit;		//跌停价

    double		total_volume;		//总成交量
    double		volume;				//成交量
    double		total_turnover;		//总成交额
    double		turn_over;			//成交额
    double		open_interest;		//总持
    double		diff_interest;		//增仓

    uint32_t	trading_date;		//交易日,如20140327
    uint32_t	action_date;		//自然日期,如20140327
    uint32_t	action_time;		//发生时间,精确到毫秒,如105932000
    uint32_t	reserve_;			//占位符

    double		pre_close;			//昨收价
    double		pre_settle;			//昨结算
    double		pre_interest;		//上日总持

    double		bid_prices[10];		//委买价格
    double		ask_prices[10];		//委卖价格
    double		bid_qty[10];		//委买量
    double		ask_qty[10];		//委卖量
    WTSTickStruct()
    {
        memset(this, 0, sizeof(WTSTickStruct));
    }
};

#pragma pack(pop)



const int g_iTopMenuFixedHight = 35;
const int g_iAxisYVlineWidth = 60;
const int g_iAxisXAreaHeight = 35;

const QColor  TrColor_BackGround    =   QColor(21, 25, 36); //#151924
const QColor  TrColor_BackGrid      =   QColor(34, 38, 49); //#222631
const QColor  TrColor_RedKline      =   QColor(242, 54, 69);
const QColor  TrColor_GreenKline    =   QColor(8, 153, 129);
const QColor  TrColor_RedbKline     =   QColor(255, 205, 210);
const QColor  TrColor_GrebKline     =   QColor(29, 95, 94);

#endif // TRCHARTCOLOR_H
